package acm.pta4;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(in.readLine());
        String[] read=null;
        for (int i=0;i<n;i++) {
            read=in.readLine().split(" ");
            String sex=read[0];
            float height=Float.parseFloat(read[1]);
            if(sex.contains("M")&&height>=1.0&&height<=3.0)
                System.out.printf("%.2f\n",height/1.09);
            if(sex.contains("F")&&height>=1.0&&height<=3.0)
                System.out.printf("%.2f\n",height*1.09);
        }
    }
}

